﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
using System.IO;
using RemoteDownload.Contract;
using RemoteDownload.Domain.Model.FileManagerAggregateRoot;

namespace RemoteDownload.Service
{
    [ServiceContract]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
    public class StreamService
    {
        [WebInvoke(UriTemplate = "Download", Method = "POST")]
        public Stream Download(string url)
        {
            throw new NotImplementedException();
        }

        [WebInvoke(UriTemplate = "GetDownloadList", Method = "POST")]
        public GetDownloadListResponse GetDownloadList(GetDownloadListRequest request)
        {
            var response = new GetDownloadListResponse();
            var fileManager = FileManagerFactory.GetFilesByFilter(request);
            response.Files = Domain.Adapter.ContractConverter.GetDownloadListResponseConverter(fileManager.Files);
            return response;
        }
    }
}
